import { getAllPerson } from "libs/api/base"

export const ADD_BASE_DEPARTMENT = "ADD_BASE_DEPARTMENT";//添加主部门
export const CHANGE_ORGANIZES = "CHANGE_ORGANIZES";//修改组织
export const CHANGE_ORGANIZES_NAME = "CHANGE_ORGANIZES_NAME";//修改组织名称
export const GET_ALL_PERSON = "GET_ALL_PERSON";//获取所有人员信息
export const GET_CURRENT_PERSON = "GET_CURRENT_PERSON";//获取当前部门人员
export const ADD_ADMIN = "ADD_ADMIN";//获取部门对应人员
export const DELETE_PERSON = "DELETE_PERSON";//删除人员
export const UPDATE_PERSON = "UPDATE_PERSON";//更新人员信息
export const ADD_PERSON = "ADD_PERSON";//新增人员
export const REMOVE_MANAGER = "REMOVE_MANAGER";//移除管理员
/**
 * 新增主部门
 * @param data
 * @returns {function(*)}
 */
export function addMainDepartment(data) {
  return (dispatch) => {
      dispatch({
          type: ADD_BASE_DEPARTMENT,
          data
      })
  }
}
/**
 * 修改组织信息 批量修改
 * @param data
 * @returns {function(*)}
 */
export function changeOrganize(data) {
    return (dispatch) => {
        dispatch({
            type:CHANGE_ORGANIZES,
            data
        })
    }
}
/**
 * 修改组织名称
 * @param data
 */
export function renameOrganize(data) {
    return (dispatch) => {
        dispatch({
            type:CHANGE_ORGANIZES_NAME,
            data
        })
    }
}
/**
 * 获取所有人员
 */
export function getPerson() {
    return async (dispatch)=>{
        let data = await getAllPerson();
        dispatch({
            type:GET_ALL_PERSON,
            data
        })
    }
}
/**
 * 新增管理员
 * @param data
 * @returns {function(*)}
 */
export function addAdmin(data) {
    return (dispatch)=>{
        dispatch({
            type:ADD_ADMIN,
            data
        })
    }
}
/**
 * 移除管理员
 * @param data
 * @returns {function(*)}
 */
export function removeManager(data) {
    return (dispatch)=>{
        dispatch({
            type:REMOVE_MANAGER,
            data
        })
    }
}
/**
 * 删除员工
 * @param data
 * @returns {function(*)}
 */
export function delPerson(data) {
    return (dispatch)=>{
        dispatch({
            type:DELETE_PERSON,
            data
        })
    }
}
/**
 * 新增人员
 * @param data
 * @returns {function(*)}
 */
export function addPerson(data) {
    return (dispatch)=>{
        dispatch({
            type:ADD_PERSON,
            data
        })
    }
}
/**
 * 更新人员信息
 * @param data
 * @returns {function(*)}
 */
export function updatePerson(data) {
    return (dispatch)=>{
        dispatch({
            type:UPDATE_PERSON,
            data
        })
    }
}
